<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template function</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../attributes.html#header.boost.log.attributes.function_hpp" title="Header &lt;boost/log/attributes/function.hpp&gt;">
<link rel="prev" href="../fallback_to_default.html" title="Struct template fallback_to_default">
<link rel="next" href="function/impl.html" title="Class impl">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../fallback_to_default.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.function_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="function/impl.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.attributes.function"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template function</span></h2>
<p>boost::log::attributes::function — A class of an attribute that acquires its value from a third-party function object. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../attributes.html#header.boost.log.attributes.function_hpp" title="Header &lt;boost/log/attributes/function.hpp&gt;">boost/log/attributes/function.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> R<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="function.html" title="Class template function">function</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">attribute</span> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">R</span> <a name="boost.log.attributes.function.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>  <span class="comment">// The attribute value type. </span>

  <span class="comment">// member classes/structs/unions</span>

  <span class="comment">// Base class for factory implementation.</span>

  <span class="keyword">class</span> <a class="link" href="function/impl.html" title="Class impl">impl</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">attribute</span><span class="special">::</span><span class="identifier">impl</span> <span class="special">{</span>
  <span class="special">}</span><span class="special">;</span>

  <span class="comment">// Factory implementation.</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
  <span class="keyword">class</span> <a class="link" href="function/impl_template.html" title="Class template impl_template">impl_template</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">impl</span> <span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="comment">// <a class="link" href="function/impl_template.html#boost.log.attributes.function.impl_templateconstruct-copy-destruct">construct/copy/destruct</a></span>
    <span class="keyword">explicit</span> <a class="link" href="function/impl_template.html#idm25296-bb"><span class="identifier">impl_template</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

    <span class="comment">// <a class="link" href="function/impl_template.html#idm25288-bb">public member functions</a></span>
    <span class="keyword">virtual</span> <a class="link" href="../attribute_value.html" title="Class attribute_value">attribute_value</a> <a class="link" href="function/impl_template.html#idm25289-bb"><span class="identifier">get_value</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="special">}</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="function.html#boost.log.attributes.functionconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">explicit</span> <a class="link" href="function.html#idm25312-bb"><span class="identifier">function</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="function.html#idm25319-bb"><span class="identifier">function</span></a><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="function.html#idm25304-bb">private member functions</a></span>
   <a class="link" href="function.html#idm25305-bb"><span class="identifier">BOOST_STATIC_ASSERT_MSG</span></a><span class="special">(</span><span class="special">!</span><span class="identifier">is_void</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
                           <span class="string">"Boost.Log: Function object return type must not be void"</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm33446"></a><h2>Description</h2>
<p>The attribute calls a stored nullary function object to acquire each value. The result type of the function object is the attribute value type.</p>
<p>It is not recommended to use this class directly. Use <code class="computeroutput">make_function</code> convenience functions to construct the attribute instead. </p>
<div class="refsect2">
<a name="idm33451"></a><h3>
<a name="boost.log.attributes.functionconstruct-copy-destruct"></a><code class="computeroutput">function</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">explicit</span> <a name="idm25312-bb"></a><span class="identifier">function</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> fun<span class="special">)</span><span class="special">;</span></pre>
<p>Initializing constructor </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm25319-bb"></a><span class="identifier">function</span><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&amp;</span> source<span class="special">)</span><span class="special">;</span></pre>
<p>Constructor for casting support </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm33486"></a><h3>
<a name="idm25304-bb"></a><code class="computeroutput">function</code> private member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"> <a name="idm25305-bb"></a><span class="identifier">BOOST_STATIC_ASSERT_MSG</span><span class="special">(</span><span class="special">!</span><span class="identifier">is_void</span><span class="special">&lt;</span> <span class="identifier">R</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
                         <span class="string">"Boost.Log: Function object return type must not be void"</span><span class="special">)</span><span class="special">;</span></pre></li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2021 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../fallback_to_default.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.function_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="function/impl.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
